// MultiNozzleSelector.cpp: implementation of the MultiNozzleSelector class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MultiNozzleSelector.h"
#include "Equip.h"
#include "Nozzle.h"
#include "EquipManager.h"
#include "NozzleManager.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

MultiNozzleSelector::MultiNozzleSelector()
{
	SetSelectorType(NozzleType);
}

MultiNozzleSelector::~MultiNozzleSelector()
{
	if(m_NozzleList.IsEmpty())
	{
		m_NozzleList.RemoveAll();
	}
}

void MultiNozzleSelector::FindObject()
{
	if(!IsContinue()) return;		
	ASSERT(!GetOwnerId().IsNull());

	Equip* pEquip = NULL;
	UESoft::ErrorStatus nState = 
		GetCurEquipManager().FindEquip(GetOwnerId() , pEquip);
	if( nState != UESoft::eManagerSuccess)
	{
		SetState(Select_ObjNotExisted);
		return;
	}
	
	Nozzle* pNozzle = NULL;
	nState = pEquip->GetNozzleManager().FindNozzle(GetCurObjId() ,pNozzle);
	if( nState != UESoft::eManagerSuccess)
	{
		SetState(Select_ObjNotExisted);
		return;
	}
	
	m_NozzleList.AddTail(pNozzle);
	SetState(Select_Success);
}

void MultiNozzleSelector::GetSelected(NozzleList* pNozzleList)
{
	ASSERT(pNozzleList!=NULL);
	POSITION pos = m_NozzleList.GetHeadPosition();
	for(int i =0;i < m_NozzleList.GetCount() ; i++)
	{
		pNozzleList->AddTail(m_NozzleList.GetNext(pos));
	}
}
